import Vue from 'vue'
import Vuex from 'vuex'
import { Message } from 'element-ui'

Vue.use(Vuex)

const myStore = new Vuex.Store({
  state: {
    userInfo: {}
  },
  mutations: {
    /**
     * 事件
     */
  },
  getters: {
    /**
     * message提示
     * @param string: 提示语，type: 1是成功，0是失败
     * @returns {Function}
     */
    getMesg: (state) => (string, type) => {
      if (type === 1) {
        Message({
          message: string,
          type: 'success',
          duration: 1500
        })
      } else if (type === 0) {
        Message({
          message: string,
          type: 'error',
          duration: 1500
        })
      }
    }
  },
  actions: {
    /**
     *
     */
  }
})

export default myStore
